<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsf/composite/componentes"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui">
    
    <h:form prependId="false">

            <fieldset>
                <legend>Filtro</legend>
                <h:panelGrid>
                    <h:outputLabel value="#{i18n.papel_nome}"/>
                    <h:inputText id="nome" value="#{consultarPapel.descricao}" size="50"/>
                    <h:commandButton styleClass="commandButton" value="Consultar" action="#{consultarPapel.pesquisar}">
                        <f:ajax execute="nome dataTable" render="dataTable primeiro anterior proximo ultimo pagina"/>
                    </h:commandButton>
                </h:panelGrid>
            </fieldset>

            <br/>
            
            <h:dataTable id="dataTable"  value="#{consultarPapel.lista}" var="papel" styleClass="tabela" headerClass="cabecalho" rowClasses="ultimo,primeiro"  width="100%">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="#{i18n.papel_descricao}"/>
                    </f:facet>
                    <h:outputText value="#{papel.descricao}"/>
                </h:column>
                <h:column>
                    <h:commandLink title="clique aqui para selecionar" onclick="painelConsultarPapel.hide()">
                        <f:ajax render="@form"/>
                        <h:graphicImage value="#{resource['img:selecionar.png']}" style="border: 0px;"/>
                        <f:setPropertyActionListener target="${alvo}" value="#{papel}"/>
                    </h:commandLink>
                </h:column>                
            </h:dataTable>

            <h:panelGrid columns="5" cellpadding="0" cellspacing="5" style="text-align:right">
                <h:commandLink id="primeiro" value="Primeiro" action="#{consultarPapel.primeira}" disabled="#{consultarPapel.primeiroRegistro == 0}">
                    <f:ajax execute="dataTable" render="dataTable primeiro anterior proximo ultimo pagina"/>
                </h:commandLink>
                <h:commandLink id="anterior" value="Anterior"  action="#{consultarPapel.anterior}" disabled="#{consultarPapel.primeiroRegistro == 0}">
                    <f:ajax render="dataTable primeiro anterior proximo ultimo pagina"/>
                </h:commandLink>
                <h:commandLink id="proximo" value="Próximo" action="#{consultarPapel.proxima}" disabled="#{consultarPapel.primeiroRegistro + consultarPapel.registrosPorPagina >= consultarPapel.totalRegistros}">
                    <f:ajax render="dataTable primeiro anterior proximo ultimo pagina"/>
                </h:commandLink>
                <h:commandLink id="ultimo" value="Último" action="#{consultarPapel.ultima}" disabled="#{consultarPapel.primeiroRegistro + consultarPapel.registrosPorPagina >= consultarPapel.totalRegistros}">
                    <f:ajax execute="dataTable" render="dataTable primeiro anterior proximo ultimo pagina"/>
                </h:commandLink>
                <h:outputText id="pagina" value="Page #{consultarPapel.paginaCorrente} / #{consultarPapel.totalPaginas}" />
            </h:panelGrid>

        </h:form>
    
</ui:composition>